<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<jsp:useBean id="pageBean" scope="request" class="com.agileai.hotweb.domain.PageBean"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>数据库操作拦截器设置</title>
<%@include file="/jsp/inc/resource.inc.jsp"%>
<script language="javascript">
function saveInterceptorCfg(){
	if (validation.checkNull(ele('processCode').value)){
		writeErrorMsg('流程编码不能为空！');
		return;
	}
	if (validation.checkNull($('#activityCode').val())){
		writeErrorMsg('等待节点不能为空！');
		return;
	}
	if (validation.checkNull($('#bizRecordId').val())){
		writeErrorMsg('业务主键不能为空！');
		return;
	}
	postRequest('form1',{actionType:'save',onComplete:function(rspText){
		if ("success" == rspText){
			parent.refreshInterceptor();
			parent.PopupBox.closeCurrent();
		}
	}});		
}

function selectActivityCode(){
	if (validation.checkNull(ele('processCode').value)){
		writeErrorMsg('流程编码不能为空！');
		return;
	}	
	doSubmit({actionType:'selectActivityCode',doValidate:'false'});
}

function selectProcessVar(){
	if (validation.checkNull(ele('processCode').value)){
		writeErrorMsg('流程编码不能为空！');
		return;
	}	
	doSubmit({actionType:'selectProcessVar',doValidate:'false'});
}

function deleteBizAttribute(index){
	$("#attributeIndex").val(index);
	if (validation.checkNull(ele('attrValue_'+index).value)){
		doSubmit({actionType:'deleteBizAttribute',doValidate:'false'});
	}else{
		if (confirm("确认要删除该流程变量？")){
			doSubmit({actionType:'deleteBizAttribute',doValidate:'false'});	
		}
	}
}
</script>
<style type="text/css">
.apDivStyle {
	position:absolute;
	left:120px;
	top:140px;
	width:233px;
	height:57px;
	z-index:1;
	padding:0px;
}
</style>
</head>
<body>
<form action="<%=pageBean.getHandlerURL()%>" name="form1" id="form1" method="post">
<%@include file="/jsp/inc/message.inc.jsp"%>
<table class="detailTable" cellspacing="0" cellpadding="0">
<tr>
	<th width="100" nowrap>拦截器名称</th>
	<td><input id="interceptorName" label="拦截器名称" name="interceptorName" type="text" value="<%=pageBean.inputValue("interceptorName")%>" size="24" class="text" />
</td>
</tr>
<tr>
	<th width="100" nowrap>拦截器类型</th>
	<td><input name="interceptorTypeName" label="拦截器类型" type="text" class="text" id="interceptorTypeName" value="<%=pageBean.selectText("interceptorTypeSelect",pageBean.inputValue("interceptorType"))%>" size="24" readonly="readonly" /><input name="interceptorType" type="hidden" id="interceptorType" value="<%=pageBean.inputValue("interceptorType")%>" />
</td>
</tr>
<tr>
	<th width="100" nowrap>流程编码</th>
	<td nowrap="nowrap"><input label="流程编码" name="processCode" type="text" class="text" id="processCode" value="<%=pageBean.inputValue("processCode")%>" size="44" />
    <input type="button" name="button2" id="button2" value="选择" onclick="doSubmit({actionType:'selectProcessCode',doValidate:'false'})" /></td>
</tr>
<tr>
  <th width="100" nowrap>节点编码</th>
  <td nowrap="nowrap"><input label="节点编码" name="activityCode" type="text" class="text" id="activityCode" value="<%=pageBean.inputValue("activityCode")%>" size="44" />
    <input type="button" name="button2" id="button2" value="选择" onclick="doSubmit({actionType:'selectActivityCode',doValidate:'false'})" /></td>
</tr>
<tr>
  <th width="100" nowrap>业务主键</th>
  <td><textarea onKeydown="savePos(this)" onKeyup="savePos(this)" onmousedown="savePos(this)" onmouseup="savePos(this)" onfocus="savePos(this)" label="业务主键" name="bizRecordId" cols="55" rows="2"  class="textarea" id="bizRecordId"><%=pageBean.inputValue("bizRecordId")%></textarea><img class="varselecter" src="images/varselecter.png" width="20" height="20" onclick="showVariableBox('bizRecordId')" style="cursor:pointer" title="选择变量" />
  </td>
</tr>
<%
for (int i=0;i < pageBean.getRsList().size();i++){
%>
<tr>
  <th width="100" nowrap>流程变量<br /><%=pageBean.inputValue(i,"code")%></th>
  <td>
  <input type="hidden" id="attrCode_<%=i%>" name="attrCode_<%=i%>" value="<%=pageBean.inputValue(i,"code")%>" />
  <textarea onKeydown="savePos(this)" onKeyup="savePos(this)" onmousedown="savePos(this)" onmouseup="savePos(this)" onfocus="savePos(this)" label="变量" name="attrValue_<%=i%>" cols="55" rows="2"  class="textarea" id="attrValue_<%=i%>"><%=pageBean.inputValue(i,"value")%></textarea><img class="varselecter" src="images/varselecter.png" width="20" height="20" onclick="showVariableBox('attrValue_<%=i%>')" style="cursor:pointer" title="选择变量" />
  <img class="varselecter" src="images/delete.gif" width="20" height="20" onclick="deleteBizAttribute('<%=i%>')" style="cursor:pointer" title="删除" />  
  </td>
</tr>
<%} %>
</table>
<input type="hidden" name="actionType" id="actionType" value=""/>
<input type="hidden" id="WFA_ID" name="WFA_ID" value="<%=pageBean.inputValue("WFA_ID")%>" />
<input type="hidden" id="positionType" name="positionType" value="<%=pageBean.inputValue("positionType")%>" />
<input type="hidden" id="interceptorId" name="interceptorId" value="<%=pageBean.inputValue("interceptorId")%>" />
<input type="hidden" id="attributeSize" name="attributeSize" value="<%=pageBean.inputValue("attributeSize")%>" />
<input type="hidden" id="attributeIndex" name="attributeIndex" value="" />
<div style="text-align:center">
<input type="button" class="formbutton" name="button5" id="button5" value="保存" onclick="saveInterceptorCfg()" />
&nbsp;&nbsp;
<input type="button" class="formbutton" name="button" id="button" value="上一步" onclick="goToBack()" <%=pageBean.disabled(pageBean.isValid(pageBean.inputValue("interceptorId")))%> />
&nbsp;&nbsp;
<input type="button" class="formbutton" name="button" id="button" value="取消" onclick="javascript:parent.PopupBox.closeCurrent();" />
&nbsp;&nbsp;
<input type="button" class="formbutton" name="button" id="button" value="添加流程变量" onclick="selectProcessVar()" />
</div>
<jsp:include page="/jsp/inc/varselecter.inc.jsp" flush="true" />
</form>
</body>
</html>
<script language="javascript">
requiredValidator.add("interceptorName");
<%
if (pageBean.isTrue(pageBean.inputValue("skipFirstManual"))){
%>
$("#skipFirstManual").attr("checked","checked");
<%}%>
</script>
<%@include file="/jsp/inc/scripts.inc.jsp"%>
